﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPCByMessages
{
    public interface IMessagesChannel
    {
        /// <summary>
        /// Gets whether MessagesChannel is active
        /// </summary>
        bool Active { get; }

        /// <summary>
        /// Gets whether current IMessagesChannel realization is server or client.
        /// </summary>
        bool IsServerSide { get; }

        /// <summary>
        /// Send message
        /// </summary>
        /// <param name="data">Data to send</param>
        void SendMessage(params byte[] data);

        /// <summary>
        /// Close connection and release all resources.
        /// Channel becomes not usable after call.
        /// </summary>
        void Close();

        /// <summary>
        /// Occurs when new message received
        /// </summary>
        event DataEventHandler MessageReceived;

        /// <summary>
        /// Occures when the connection is terminated by other side
        /// and data transfer becomes not available.
        /// After this event this instanse becomes  not usable anymore.
        /// </summary>
        event EventHandler Disconnected;
    }
}
